Skip to content

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Oct 15, 2025

In this PR, the database batch for writing the history index data is pre-allocated.

It's observed that database batch repeatedly grows the size of the mega-batch,
causing significant memory allocation pressure. This approach can effectively
mitigate the overhead.

Copy link
Member

@MariusVanDerWijden MariusVanDerWijden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

Comment on lines +163 to +167
switch b.typ {
case typeStateHistory:
size = estimatedStateHistoryIndexSize
case typeTrienodeHistory:
size = estimatedTrienodeHistoryIndexSize
Copy link
Member

@gballet gballet Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no default here? is using 0 future-proof?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tracked the use, but I didn't go all the way down. I see pebble uses the size to do something like mallocgc, and then does slice arithmetic on it. I would return a save value just to be sure it doesn't panic.,

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the default here. It's only possible to have state history or trienode history, we can panic for unknown type.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k, I was hoping for a warning, but I agree that this is not a concern right now. It's just the future-proofiness I was considering. Nvm I'll merge.

@gballet gballet added this to the 1.16.6 milestone Oct 21, 2025
@gballet gballet merged commit 0a8b820 into ethereum:master Oct 21, 2025
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants